<template>
	<view class="top-box">
		<view class="search-box">
			<view class="s-ipu">
				<img src="../static/images/fdj.png" class="fdj"></img>
				<input placeholder="请输入名称" v-model="content" class="input" maxlength="20" @input="updateList"></input>
			</view>
			<view class="s-btn">
				<u-button text="搜索" :hairline="false" :customStyle="searchBtnStyle" shape="circle" color="#386FFF"
					@click="toSearch" size="small"></u-button>
			</view>
			<view class="clear-tool" @click="clearCont">
				<img src="../static/images/cha.png" v-if="content.length>0"></img>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				content: '',
			}
		},

		methods: {
			clearCont() {
				this.content = ''
				this.$emit('updateList', this.content)
			},
			toSearch() {
				this.$emit('toSearch', this.content)
			},
			updateList() {
				this.$emit('updateList', this.content)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.s-ipu {
		display: flex;
		align-items: center;
		position: relative;
		font-size: 12px;
		width: 100%;

		.fdj {
			position: absolute;
			left: 20rpx;
			top: 15rpx;
			width: 24rpx;
			height: 24rpx;
		}


		.input {
			padding-left: 60rpx;
			height: 50rpx;
			line-height: 50rpx;
			width: 60%;
		}

	}


	.clear-tool {
		width: 64rpx;
		height: 64rpx;
		position: absolute;
		top: 0;
		right: 120rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		z-index: 9;

		image {
			width: 28rpx;
			height: 28rpx;
		}
	}

	.top-box {
		padding: 20rpx 30rpx 10rpx;
		background: #fff;

		.search-box {
			position: relative;
			height: 64rpx;
			background: #f3f4f9;
			border-radius: 64rpx;
			display: flex;
			align-items: center;
			overflow: hidden;
			border-radius: 100px;

			.s-btn {
				position: absolute;
				width: 118rpx;
				height: 54rpx;
				right: 7rpx;
				top: 7rpx;
				z-index: 9;

				/deep/ .u-button__text {
					font-size: 24rpx !important;
				}
			}
		}
	}
</style>